Processor for processing data string by byte-by-byte

ABSTRACT

A data processor processes data strings from memory where the data strings do not begin or end at a memory boundary. A string is defined in memory by a starting address, a byte count defining the total number of bytes in the string, and a byte offset defining the position of the first byte in the starting address location. The processor stores the byte count and decrements the byte count as each multi-byte word is processed. A byte count mask circuit generates a byte count mask which has all 1s for each byte count greater than the number of bytes per memory word. When the number of bytes remaining to be processed is below the number of bytes in a memory word, the byte count mask generates 1s only for the positions corresponding to the positions of bytes of the string in the last memory word. An offset register stores the offset defining the position of the first byte in the first memory word of the string. The offset is used to shift the byte count mask by a number of positions corresponding to the position of the first byte of the string and inserts 0s in the byte count mask for positions not belonging to the string. A byte-by-byte comparator determines string end conditions and provides an output word with a significant bit indication for each byte for which an end condition has been detected. The output of the byte-by-byte comparator is combined with the shifted byte count mask, and the result is decoded by means of a prioritized decoder which generates a string write mask.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The invention relates to data processing systems and more particularly to processors which process data strings in a data processor system.

2. Prior Art

Data processing systems are designed to operate on data stored in memory and to perform a variety of operations with respect to the data. Data is typically stored in memory in the form of data words which may be several bytes in length, e.g., eight bytes of eight binary bits each. Certain types of data is presented in the form of a data string which comprises a number of bytes, oftentimes greater than the number of bytes that can be stored in a single memory word, and the number of bytes in a string are not necessarily a multiple of the number of bytes in a memory word. Thus, a string may fully occupy some memory words and partially occupy another. Furthermore, for purposes of saving the memory space and for convenience to programmers, it is desirable not to require that a data string start at the beginning of a memory word or end at the end of a memory word. Under those conditions, the beginning portion of a data string may partially occupy one memory word location and the ending portion of the string may partially occupy another memory word location.

There are a number of known processor instructions for manipulating data strings such as the MOVE instruction which causes the data string to be moved from one memory location to another; the SEARCH instruction which searches the contents of the memory string for certain predefined conditions; and COMPARE instructions which compare the bytes in two separate strings to determine equality conditions. A data string is typically defined by a starting address and data defining the number of bytes in the string. String manipulation, by means of such instructions as mentioned above, may be executed by the use of a program subroutine which takes into account the memory word boundary conditions during manipulation of the string. However, such software manipulation is rather complex and therefore time consuming to the data processor. It is therefore desirable to provide an alternative in which data strings may be processed more efficiently.

SUMMARY OF THE INVENTION

These and other problems of the prior art are overcome in accordance with the present invention by providing hardware internal to a data processor for rapidly executing data string manipulation instructions.

In accordance with one aspect of the invention, a data processor comprises end condition detection circuitry generating a multi-bit output word in which certain bits are significant condition bits defining the presence of an end condition for a correspondingly positioned byte of data read from memory. A mask circuit generates a mask having significant condition bits indicating bytes of the data word belonging to the data string and logic circuitry generates a multi-bit end condition output word defining bytes of the data word and belonging to the data string for which an end condition has been detected. A further mask circuit generates an output mask defining only bits of the end condition output word up to and including the first significant condition bit of the end condition output word. A second logic circuit generates a multi-bit output word having a significant bit in the position corresponding to the first byte in the data word representing an end condition and significant bits representing all other bytes belonging to the string and positioned between the first end condition byte and one end of the data word.

In one embodiment of the invention, the end condition detection circuitry provides an end condition indication when a byte of the data string is an end character. In another embodiment of the invention, the data processor reads a plurality of bytes of each of a pair of strings, and upon comparison of correspondingly positioned bytes of the two strings, generates an end condition output word defining equality conditions, e.g., equal, not equal, less than, greater than, of corresponding bytes of the two strings.

Advantageously, in accordance with this invention, a data string processing arrangement does not require that data strings are started or ended on a memory word boundary, thereby significantly reducing memory space required for string storage and simplifying memory loading procedures. Furthermore, time-consuming software string manipulation is avoided.

DETAILED DESCRIPTION OF THE DRAWING

An illustrative embodiment of the invention is described below with reference to the drawing in which:

FIG. 1 is a block diagram representation of a computer system incorporating the principles of the invention;

FIG. 2 is a more detailed block diagram representation of string processing logic circuitry of FIG. 1;

FIGS. 3, 4, and 5 are more detailed block diagram representations of logic circuitry of FIG. 2;

FIGS. 6 through 9 are tables expressing logical relationships of signals generated within the processor system of FIG. 1; and

FIG. 10 is a layout of a multi-byte data string in the memory of FIG. 1.

DETAILED DESCRIPTION

FIG. 1 is a high-level block diagram representation of a computer system including a memory of 10 and a central processing unit (CPU) 12. The CPU 12 communicates with the memory unit 10 by means of a memory bus 15. Data is stored in the memory 10 in a plurality of individually addressable locations referred to as memory words. The CPU 12 processes data on the basis of data bytes, with each byte containing eight binary data bits. Each memory word contains several such bytes of data. A data string consists of a plurality of associated data bytes, all of which may be stored in one memory word or in several contiguous data words, depending on the length of the string. Data strings are defined by a starting address and a byte count indicative of the length of the string. A string may also include an end character defining the end of the string.

String manipulation instructions such as MOVE, COMPARE, and SEARCH operate on data strings in storage. Such instructions typically process the strings on a byte-by-byte basis.

The MOVE instruction moves a data string from a specified location to another location in memory. The COMPARE instruction compares two data strings in memory on a byte-by-byte basis. The SEARCH instruction searches a data string for a specified sequence of data bits. In the system of this invention a data string does not necessarily start or end on a word boundary. The start of the data string is defined by a starting memory word address in which the first byte of the string is stored. An offset indicates the position of the first byte in the starting memory word. An end character in the last byte of the string identifies the end of the string.

The string manipulation instructions are executed by means of the processor 12 by first reading the eight-byte memory word defined by the starting address. In the system accorded with the invention, the processor 12 is provided with an A register, a B register and a C register, 21, 22 and 23, respectively, each eight bytes in length. The A register holds up to eight bytes of a string for the MOVE and SEARCH instructions and a first operand for the COMPARE instruction. The B register holds up to eight bytes of a second operand for the COMPARE instruction, and the C register holds the predefined end character, replicated eight times.

String processing logic 25 processes the strings in the CPU 12. An instruction controller 30 is connected to the processing logic 25 to differentiate between processing for the MOVE, SEARCH, and COMPARE instructions. The byte count specifying the number of bytes to be processed in this string, if no other ending conditions are reached, is stored in a byte count register 31. An offset value representing the starting point of the first useful byte in the starting memory location is defined by the contents of a byte offset register 32.

FIG. 2 is a block diagram representation of the string processing logic 25 of FIG. 1. The string processing logic 25 receives inputs from the A, B and C registers, 21, 22 and 23, on conductors 26, 27 and 28, respectively, and from the instruction controller 30, the byte count register 31 and the byte offset register 32 (FIG. 1) on conductors 41, 42 and 43, respectively. A byte-by-byte comparator 107 receives the eight-byte contents of the A, B, and C registers on cables 26, 27, and 28, respectively, and generates a set of three output signals Xi, Yi, Zi on cable 123 for each of the eight bytes in the A, B, and C registers 21, 22, 23. Each of the X, Y, and Z output signals represents a logical combination of corresponding bytes of one or more of the A register, B register, and C register defining equality conditions (equal, not equal, less than, greater than) of corresponding bytes of these registers. Specifically, the eight Xi signals are 1 if and only if the i-th byte of the A register is the end character; the eight Yi signals are 1 if and only if the i-th byte of the A register is greater than the i-th byte of the B register or if the i-th byte of the B register is equal to the end character while the i-th byte of the A register is not; the eight Zi signals are 1 if and only if the i-th byte of the A register is less than the i-th byte of the B register. This relationship is also shown by equations in Table C, FIG. 8. The specific logic for implementing the byte-by-byte comparator 107 is described later herein with reference to FIG. 3.

The signals Xi, Yi and Zi are applied to the write mask circuit 121 via cable 123. This circuit is responsive to these inputs and an input from the instruction controller 30 on conductor 41 to generate an output signal on cable 125 referred to as END COND and indicative of an end condition detected in a data string being processed. This signal is in the form of a multi-bit mask which defines those bytes of the A register for which a valid end condition has been detected. The selector decoder 109 is responsive to this end condition signal on cable 125 and an output from the instruction controller 30 on conductor 41 to generate a status output on output 49 which includes an end-of-string character indication as well as an indication of comparison between the A and B registers for COMPARE instructions. The output of the instruction controller 30 on conductor 41 is used in both the write mask circuit 121 and selector/decoder 109 since different functions are to be performed by these circuits for COMPARE instructions than for the MOVE and SEARCH instructions. The write mask circuit 121 is responsive to the instruction controller input on conductor 41 and outputs from the byte count register 31 and the byte offset register 32 on conductors 42 and 43 respectively, to generate a write mask on cable 48. This write mask is an eight-bit mask that reflects the number of bytes and the position of the bytes of the string processed in the current iteration. Each bit in the write mask represents a byte of the eight-byte A register. The write mask is used in the MOVE instruction to write the data string into a new memory location. The write mask generator 121 further generates an output on conductor 44 which is the new byte count to be entered in the byte count register 31, as is described later herein with reference to FIG. 4. In this manner, the byte count register is updated to accurately reflect the number of bytes left to be processed.

FIG. 3 is a more detailed block diagram representation of the byte-by-byte comparator 107 of FIG. 2. Outputs from the A, B and C registers, identified as A0 through A7, B0 through B7 and C0 through C7, respectively, are applied to logic circuits 130. The designations A0 through A7, B0 through B7 and C0 through C7 refer to bytes 0 through 7 of the respective eight-byte registers. There are eight logic circuits 130 in the comparator 107, with the first logic circuit receiving byte 0 of the three registers and the next logic circuit receiving byte 1 of the three registers, etc., with the last of the logic circuits receiving byte 7 of the three registers. Each of the circuits 130 generate an X, Y, and Z output signal with the leftmost one of the circuits 130 shown in FIG. 3 generating bits X0, Y0 and Z0 and the other circuits generating bits X1, Y1, Z1 through X7, Y7, Z7. The relationship of Xi, Yi, Zi to bytes Ai, Bi, and Ci is shown in Table C (FIG. 8).

The logic circuits 130 are identical in structure and only one of the circuits is shown in greater detail. Each of the circuits 130 has four well-known byte-by-byte comparator circuits 131 through 134. The output of comparator 131 is a logical 1 when byte A0 is equal to byte C0; comparator 132 output is a logical 1 when byte A0 is greater than byte B0; comparator 133 output is a logical 1 when byte B0 is equal to byte C0; and comparator 134 output is a logical 1 when byte A0 is equal to byte B0.

As can be readily seen from the drawing, the output X0 is a logical 1 if A0 is equal to C0. The outputs of comparators 131 and 133, individually indicating that A0 is equal to C0 and B0 is equal to C0, are applied to an AND circuit 136 with the input from logic circuit 131 being inverted. Accordingly, the output of circuit 136 indicates that A0 is not equal to C0 and B0 is equal C0. The output of AND circuit 136 is applied to OR circuit 138 together with the output of comparators 132 which indicates that A0 is greater than B0. Accordingly, the output Y0 is a logical 1 whenever A0 is greater than B0 or, B is equal to C0 and A0 is not equal to C0. The output of logic circuits 132 and 134 are applied to AND circuit 140 and both inputs are inverted. Accordingly, the output Z0 is a 1 when A0 is not equal to B0 and A0 is not greater than B0. This is equivalent to the statement that A0 is less than B0.

FIG. 4 is a more detailed block diagram representation of the write mask circuit 121 of FIG. 2. The write mask circuit includes a byte count mask circuit 150 which produces an eight-bit output mask having a number of 1s corresponding to the byte count in the byte count register 31 of FIG. 1 to which this circuit is connected by means of conductor 42. The relationship between the byte count in register 31 and the mask output circuit 150 is shown in tabular form in Table D, FIG. 9. The byte count in register 31 initially represents the number of bytes in the string to be processed. This number is decremented as bytes are processed and therefore represents the number of bytes to be processed at each stage of string processing. The byte count mask is used together with the contents of the Byte offset register 32 to define the position of the first and last bytes of a data string. Since a data word does not necessarily start or end on a word boundary, the byte count and offset are used to provide a mask which allows only those bytes of a memory word belonging to the data string to be processed. String processing is performed in sequential order from left to right, from the lowest numbered byte to the highest. By way of example, FIG. 10 depicts a memory layout of 13 double word memory locations of 16 bytes each, for storing 26 eight-byte words. A data string having its first byte, byte 1, in byte position 5 of the first word and having the last byte, byte 200, in byte position 4 of the 26th word, is depicted in FIG. 10. In this example, the byte count in register 31 is initially 200 and the offset in register 32 is 5. When memory data word 00 is loaded into register A, the byte count is 200 and the eight-bit byte count mask is all 1s, as depicted in Table D, FIG. 9.

The byte count mask produced by the circuit 150 is applied to a shift register 151 wherein the entire mask is shifted to the right by an amount defined by binary bits on the conductor 43 which represent the contents of the byte offset register 32. The shift is made to the right and 0s are inserted at the left as the content is shifted to the right. Thus, in the example of FIG. 10 where the offset is equal to 5, the byte count mask is shifted to the right by five positions and 0s are inserted in the leftmost five positions. Accordingly, the resultant mask has is only in positions corresponding to bytes 1, 2 and 3 of the data string. For all subsequently read memory words after the first memory word in the string, the offset is 0. The byte count is decremented with each subsequently processed group of bytes and the byte count mask is not affected by the offset. For the next 24 eight-byte words read from memory, the byte count, at the time the next word is read, will be greater than 8. When the 25th word, i.e., the last word containing bytes of the string, is read, the byte count will be 5 (i.e., 200-195). The corresponding byte count mask, as shown in FIG. 9, will have is in the five leftmost positions, corresponding to the five positions of the last word containing bytes belonging to the string.

FIG. 4 includes a selector 155 which receives inputs which are functions of signals X0, Y0, Z0 through X7, Y7, Z7 on cable 123 and an input from the instruction controller 30 on conductor 41. In each case, the Xi bit is a one when the corresponding byte defines the end character, i.e., Ai=C2. Therefore, the Xi lead is used as a direct indication of the presence or absence of an end condition for the MOVE or SEARCH instructions, which use only the A register 21. As can be seen from Table A in FIG. 6, other combinations of X, Y, and Z can be used with COMPARE instructions to determine whether corresponding bytes of the A register 21 and the B register 22 are equal or unequal and whether either of these is equal to the end character in the C register 23. The particular coding shown in Table A of FIG. 6 is not unique and other codings may be used.

An end condition in this context is defined as the condition wherein byte Ai equals Ci, i.e., the end character, or wherein Ai is not equal to Bi in a COMPARE instruction. For each set of Xi, Yi, Zi inputs, a pair of OR circuits 153, 154 are provided. Circuit 153 provides a logical output equal to Xi or Yi or Zi, and circuit 154 provides a logical output Xi or Zi. The selector 155, in accordance with instruction control signals on conductor 41 selects the Xi input for MOVE and SEARCH instructions and selects the outputs of OR circuits 153, 154 for different COMPARE instructions. As can be seen with reference to Table A, FIG. 6, the Xi or Yi or Zi case represents all conditions except Ai=Bi≠Ci and Xi or Yi represents Ai≠Bi.

The output of the selector 155 is an eight-bit word with a bit corresponding to each of the eight bytes of a word being processed and a logical one indicating when the corresponding byte represents an end condition. In the AND logic 165, the eight-bit word from the selector 155 is ANDed with the eight-bit mask of shift register 151. The function of the AND logic 165 is to mask off irrelevant bits as determined from the byte count and the offset by means of the byte count mask circuit 150 and the shift register 151, as discussed earlier herein. An end condition mask is generated in the decoder 170 in accordance with Table B (FIG. 7). The Table B indicates the bit positions of the end conditions and the corresponding mask in hexadecimal notation. The corresponding decimal numbers are indicated in parentheses. The decoder 170 is a prioritized decoder which finds the leftmost 1 and produces an output mask word with all 0s to right of the leftmost 1. In the AND logic 172 an eight-bit output signal, VALID BYTE 0 through VALID BYTE 7 is created by ANDing the end condition mask on cable 171 with the shifted byte count mask on cable 159. Since the latter identifies bytes of the string, the resultant output of AND logic 172 is an eight-bit word identifying exactly those bytes that participated in the current processing iteration of the string instruction. This output is used on output 48 as a write mask for the MOVE instruction when the string is stored in a new location. The output 48 is also used in arithmetic logic circuitry such as counter circuit 175 which counts the number of is in the eight-bit write mask, since this indicates the number of bytes in the current iteration of the string instruction. By means of an adder 176, this number is subtracted from the byte count number transmitted from the byte count register 31 on conductor 42. The resultant output of adder 176 is the new byte count and this value is inserted in the byte count register 31 via conductor 44.

FIG. 5 is a more detailed representation of the selector/decoder circuit 109 of FIG. 2. The selected decoder circuit 109 comprises an X selector 180, a Y selector 181, and a Z selector 182. The selectors 180, 181, and 182 are prioritized selectors. Each of the selectors has its input the eight-bit end condition word from write mask circuit 121, cable 125, and an eight-bit X, Y, or Z word on cable 123. These X, Y, Z signals are generated from the A register, B register and C register bytes and define the end condition. Each prioritized selector identifies the position of the leftmost 1 of the end condition word and generates an X, Y or Z output signal, on conductors 185 through 187, which corresponds to one of the X, Y, or Z inputs defined by the leftmost 1. By way of example, if the first 1 in the end condition word is at position 2, the X2, the Y2, and the Z2 inputs will be reproduced on the output conductors 185 through 187.

A decoder circuit 190 receives the 7 bit word defining the end condition from the write mask circuit 121 on cable 125. It also receives an input from the instruction controller 30 on conductor 41. If the end condition on cable 125 is all 0s, no data-dependent terminating condition has been reached. However, if the end condition is non-zero or the new byte count on conductor 44 equals 0, then the instruction should terminate on the Current iteration. For the MOVE and SEARCH instructions only the X value has meaning and when the selected X input value on conductor 185 is a 1, the end character output on conductor 192 is activated. Outputs on conductors 193, 194, and 195 indicate whether A is equal to B, A is less than B, or A is greater than B, respectively. The relationships of A with respect to B can be readily derived from the Xi, Yi, Zi signals as shown in Table A (FIG. 6). It will be apparent from Table A, that A is equal B when Y and Z are both 0, A is less than B when Z is equal to 1, and A is greater than B when Y is equal to 1, and Z is equal to 0. The output of decoder 190 represents the status information on conductor 49 of FIG. 1.

It will be understood that the above-described embodiment is only illustrative of the principles of the invention and that other embodiments may be devised by those skilled in the art without departing from the spirit and scope of the invention. 

What we claim is:
 1. A data processor system comprising memory and a data processor, the memory comprising a plurality of data word locations each arranged to contain a predetermined number of data bytes and a data string stored in the memory, the data processor comprising:a data register; memory access circuitry for reading one of the data word locations containing at least a portion of the data string and storing the portion of the data string in the data register; end condition detection circuitry connected to the data register generating a multi-bit output word in which certain bits are significant condition bits defining presence of an end condition for a correspondingly positioned byte in the data register; a byte count register storing a value defining a number representing unprocessed bytes in the data string; a first mask circuit connected to the byte count register for generating a byte count mask defining positions of bytes in the data register and belonging to the data string; a first logic circuit connected to the end condition detection circuitry and to the first mask circuit for logically combining the byte count mask and the multi-bit output word of the end condition detection circuit and generating a multi-bit end condition output word defining end conditions of bytes in the data register belonging to the data string; a second mask circuit connected to the first logic circuit for detecting a first significant condition bit in a first position nearer one end of the end condition output word than any other significant bit in the end condition output word and for generating an end condition mask defining only bits of the end condition output word up to and including the first significant condition bit; a second logic circuit connected to the first mask circuit and the second mask circuit for generating a multi-bit output mask having a significant condition bit in a position corresponding to a first byte in the data register representing an end condition and a significant condition bit in each position corresponding to a byte belonging to the data string and positioned between the first byte representing an end condition and one end of the data register corresponding to the one end of the end condition output word; an offset register defining the position of a first byte of the string in a memory location with respect to one end of the memory word stored in the data register; and a shift register connected between the first mask circuit and the first logic circuit and responsive to contents of the offset register to shift the byte count mask generated by the first mask circuit in a direction away from one end of the byte count mask corresponding to the one end of the data register by a number of bit positions defined by the contents of the offset register before the multi-bit mask generated by the first mask circuit is applied to the first logic circuit.
 2. The data processor system in accordance with claim 1 wherein the data string stored in memory includes an end byte storing an end character and wherein the end condition detection circuitry includes an end character register storing the end character and wherein significant condition bits in the output word of the end detection circuitry define the presence of the end character.
 3. The data processing system in accordance with claim 1 and further comprising arithmetic logic circuitry connected to the second logic circuit and the byte count register and responsive to the output word of the second logic circuit to transmit to the byte count register a signal indicative of the number of bytes of the data string to be processed.
 4. A data processor system comprising a data storage memory and a data processor, the memory comprising a plurality of data word locations each arranged to contain a predetermined number of data bytes and first and second predefined data strings stored in selected data word locations of the memory, the data processor comprising:first and second data registers; memory access circuitry for reading one of the selected data word locations containing at least a portion of the first data string and storing the portion of the first data string into the first data register and reading one of the selected locations containing at least a portion of the second data string and storing the portion of the second data string in the second data register; end condition detection circuitry connected to the first and second data registers and including comparator circuitry for comparing correspondingly positioned bytes in the first and second registers and for generating a multi-bit comparator output word in which certain bits are significant condition bits defining equality conditions of bytes of the first and second data registers in positions in the data registers corresponding to positions of the significant bits in the end condition output word; a byte count register storing a value defining a number representing unprocessed bytes in one of the data strings; a byte count mask circuit connected to the byte count register for generating a multi-bit byte count mask defining positions of bytes in the first data register and belonging to the first data string: end condition logic circuitry connected to the end condition detection circuitry and to the mask circuit for logically combining the multi-bit byte count mask with the comparator output word and generating a multi-bit end condition output word defining end conditions of correspondingly positioned bytes in the first data register and belonging to the first data string; another mask circuit connected to the end condition logic circuitry for detecting a first significant condition bit in a first position nearer one end of the end condition output word than any other significant bit in the end condition output word and for generating an end condition mask defining only bits of the end condition output word up to and including the first significant condition bit; and logic circuitry connected to the end condition logic circuitry and the byte count mask circuit for generating a multi-bit output word having a significant condition bit in the position corresponding to the first byte in the first data register representing an end condition and all other bytes belonging to the first data string and positioned between the first byte representing an end condition and the one end of the first data register corresponding to the one end of the end condition output word.
 5. The data processor system in accordance with claim 4 and further comprising selector circuitry connected to the end condition detection circuitry and the logic circuit to provide an output defining an equality condition from which the end condition was generated in the end condition detection circuitry.
 6. The system in accordance with claim 5 wherein at least one of the first and second data strings includes an end character and wherein the end condition detection circuitry generates an end condition output word further defining the presence of an end character in one of the first and second data registers and wherein the selector circuitry further comprises an output indication indicative of the presence of an end character in one of the registers. 